<?php


namespace app\api\library\index\getUserCurrentAddress;


use think\facade\Db;

class V
{
    public static function run($param)
    {
        $userId = _checkEmptyParam($param[ 'userId' ], '用户ID不能为空');
        //查询用户的所有地址
        $where   = [
            ['user_id', '=', $userId],
            ['current', '=', 1],
            ['delete_time', '=', null],
        ];
        $address = (array) Db::name('mall_address')
            ->where($where)
            ->order(['current' => 'desc', 'id' => 'desc'])
            ->field('id,name,phone,province_id,province,city_id,city,region_id,region,detail,current')
            ->find();
        $res     = [
            $address,
        ];
        _outPut(200, $res);
    }
}